package com.heima.storage.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.storage.service.IStorageService;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mcm
 * @since 2021-09-22
 */
@RestController
@RequestMapping("/storage")
public class StorageController{

    @Autowired
    private IStorageService storageService;

    /**
     * 扣减库存
     * @param code 商品编号
     * @param count 要扣减的数量
     * @return
     */
    @PutMapping("/{code}/{count}")
    public ResponseEntity deduct(@PathVariable("code") String code, @PathVariable("count") Integer count){
        storageService.deduct(code, count);
        return ResponseEntity.ok().build();
    }

}
